package com.irenty;

public class InsertionSort implements Sort<Integer> {
	public Integer[] sort(Integer[] s) {
		int j;
		Integer temp;
		for (int i = 1; i < s.length; i++) {
			j = i;
			// insert ith element in order before ith position
			while ((j > 0) && (s[j] < s[j - 1])) {
				// swap
				temp = s[j];
				s[j] = s[j - 1];
				s[j - 1] = temp;
				j = j - 1;
			}
		}
		return s;
	}
}
